<template>
  <div>
    <el-tabs v-model="activeName" @tab-click="handleClick">
      <!-- 基本信息 -->
      <el-tab-pane label="基本信息" name="first">
        <el-table
          :data="Basics"
          stripe
          style="width: 100%"
        >
          <el-table-column prop="name" label="api名称" ></el-table-column>
          <el-table-column prop="nick" label="接口名称" ></el-table-column>
          <el-table-column prop="mode" label="API类型" ></el-table-column>
          <el-table-column prop="type" label="请求类型" ></el-table-column>
          <el-table-column prop="state" label="响应类型"></el-table-column>
          <el-table-column prop="base" label="数据库"></el-table-column>
          <el-table-column prop="basetable" label="数据表格"></el-table-column>
          <el-table-column prop="describe" label="描述"></el-table-column>
          <el-table-column label="操作">
            <template slot-scope="scope">
              <el-button size="mini" @click="basic(scope)">编辑</el-button>        
            </template>
          </el-table-column>
        </el-table>
              <!-- 基本信息   编辑模态框 -->
            <el-dialog title="收货地址" :visible.sync="dialogFormVisible">
              <el-form :model="addfrom">
                <el-form-item label="api名称" :label-width="formLabelWidth">
                  <el-input v-model="addfrom.name" autocomplete="off"></el-input>
                </el-form-item>
                  <el-form-item label="接口名称" :label-width="formLabelWidth">
                  <el-input v-model="addfrom.nick" autocomplete="off"></el-input>
                </el-form-item>
                 <el-form-item label="api类型" :label-width="formLabelWidth">
                  <el-input v-model="addfrom.mode" autocomplete="off"></el-input>
                </el-form-item>
                 <el-form-item label="请求类型" :label-width="formLabelWidth">
                  <el-input v-model="addfrom.type" autocomplete="off"></el-input>
                </el-form-item>
                 <el-form-item label="响应类型" :label-width="formLabelWidth">
                  <el-input v-model="addfrom.state" autocomplete="off"></el-input>
                </el-form-item>
                 <el-form-item label="数据库" :label-width="formLabelWidth">
                  <el-input v-model="addfrom.base" autocomplete="off"></el-input>
                </el-form-item>
                 <el-form-item label="数据表格" :label-width="formLabelWidth">
                  <el-input v-model="addfrom.basetable" autocomplete="off"></el-input>
                </el-form-item>
                 <el-form-item label="描述" :label-width="formLabelWidth">
                  <el-input v-model="addfrom.describe" autocomplete="off"></el-input>
                </el-form-item>
              </el-form>
              <div slot="footer" class="dialog-footer">
                <el-button @click="dialogFormVisible = false">取 消</el-button>
                <el-button type="primary" @click="basicmodle">确 定</el-button>
              </div>
            </el-dialog>
      </el-tab-pane>
      <!-- 参数信息 -->
      <el-tab-pane label="参数信息" name="second">
        <el-table
          :data="app"
          stripe
          style="width: 100%"
        >
          <el-table-column prop="parameter" label="参数名称" ></el-table-column>
          <el-table-column prop="parameterType" label="参数类型" ></el-table-column>
          <el-table-column prop="must" label="是否必须" ></el-table-column>
          <el-table-column prop="describetow" label="描述" ></el-table-column>
          <el-table-column label="操作">
            <template >
              <!-- <el-button size="mini">编辑</el-button> -->
            </template>
          </el-table-column>
        </el-table>
      </el-tab-pane>
      <!-- 响应信息 -->
      <el-tab-pane label="响应信息" name="third">
            <el-table
              :data="response"
              stripe
              style="width: 100%"
            >
              <el-table-column prop="name" label="表格列名" ></el-table-column>
              <el-table-column prop="nick" label="API列名" ></el-table-column>
              <el-table-column prop="mode" label="字段名称" ></el-table-column>
              <el-table-column prop="type" label="字段类型" ></el-table-column>
              <el-table-column prop="state" label="是否必须" ></el-table-column>
              <el-table-column prop="base" label="描述" ></el-table-column>
              <el-table-column label="操作">
                <template >
                  <!-- <el-button size="mini">编辑</el-button> -->
                </template>
              </el-table-column>
            </el-table>
      </el-tab-pane>
      <!-- 权限信息 -->
      <el-tab-pane label="权限信息" name="fourth">
         <el-table
              :data="iplist"
              stripe
              style="width: 100%"
            >
              <el-table-column prop="name" label="表格列名" ></el-table-column>
              <el-table-column prop="nick" label="API列名" ></el-table-column>
              <el-table-column prop="ip" label="字段名称" ></el-table-column>
              <el-table-column prop="base" label="字段类型" ></el-table-column>
              <el-table-column label="操作">
                <template >
                  <!-- <el-button size="mini">编辑</el-button> -->
                </template>
              </el-table-column>
            </el-table>
      </el-tab-pane>
    </el-tabs>
  </div>
</template>
<script>

export default {
  data() {
    return {
      activeName: "first",//默认展示top栏第一列
      tableData:[],//基本信息列表数据
      app:[],//参数信息列表数据
      response:[],//响应信息列表数据
      iplist:[],//权限信息列表数据
      dialogFormVisible: false,//基本信息编辑模态框默认不显示
      formLabelWidth: '120px',//模态框前面标题宽度
      Basics:[],//基本信息页面数据
      addfrom:[]
    };
  },
  // 钩子函数  页面打开时
  mounted(){
      this.getData(),
      this.add(),
      this.ponse(),
      this.diction(),
      this.iop()
  },
  methods: {
      //top栏切换
    handleClick(tab, event) {
      console.log(tab, event);
    },
     //axios请求获取基本信息列表数据
    getData() {
      this.axios.get("../../static/demo.json").then(res => {
        this.tableData = res.data.list;
          // console.log(this.tableData)
      }),
        res => {
          alert("请求失败");
        };
    },
    //axios请求获取参数信息列表数据
    add() {
      this.axios.get("../../static/demo.json").then(res => {
        this.app = res.data.list2;
      }),
        res => {
          alert("请求失败");
        };
    },
     //axios请求获取响应信息列表数据
    ponse() {
      this.axios.get("../../static/demo.json").then(res => {
        this.response = res.data.list3;
      }),
        res => {
          alert("请求失败");
        };
    },
    //axios请求获取q权限信息列表数据
    diction() {
         this.axios.get("../../static/demo.json").then(res => {
        this.iplist = res.data.list4;
      }),
        res => {
          alert("请求失败");
        };
    },
    // 编辑模态框展示数据
    basic(scope) {
      this.dialogFormVisible=true
        this.addfrom = JSON.parse(JSON.stringify(scope.row)) //对应列的数据显示模态框中
    },
    //点击模态框确定按钮
    basicmodle() {
      this.axios.get("../../static/demo.json?name=api1").then(res => {
   
      })    
  
         
    },
    //路由传参 获取home列表页面的数据展示到本页面
    iop() {
      this.Basics.push({
          name:this.tits.name,
          nick:this.tits.nick,
          mode:this.tits.mode,
          type:this.tits.type,
          state:this.tits.state,    
           
      })
      
    }
  },
  //  路由传参  在这边接收数据
   created() {
       this.tits = this.$route.query;          
       console.log(this.$route)
      console.log(sessionStorage.getItem('testKey'))
      // => 返回testKey对应的值
      console.log( sessionStorage['testKey'])
      // => 这是一个测试的value值
     }
};
</script>

<style>
</style>
